<?php
/**
 * Created by PhpStorm.
 * User: L
 * Date: 2018/12/5
 * Time: 10:46
 */

namespace app\controllers\Project_1_0;


use Core\Controller;

class Login extends Controller
{
function login(){
    $params = [ 'appid' => 'wx1595b492608a8157', 'secret' => 'a6eb09d6b8dac35dbfac6de2557b159d', 'js_code' => $_GET['js_code'],
   'grant_type' => 'authorization_code', ];   // 小程序传来的ticket
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.weixin.qq.com/sns/jscode2session');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $output = curl_exec($ch);
    if (false === $output) {
        echo 'CURL Error:' . curl_error($ch);
    }
    echo $output;

}
}